#include<iostream>
using namespace std;
int base_conversion(int n,int a) {
	int sum = 0;
	while (n) {
		sum += n % a;
		n /= a;
	}
	return sum;
}
int main() {
	int n, i, sum = 0;
	for (i = 1,n = 0; n < 2023; i++) {
		if (i % base_conversion(i, 2) == 0 && i % base_conversion(i, 8) == 0 && i % base_conversion(i, 10) == 0 && i % base_conversion(i, 16) == 0) {
			n++;
			sum = i;
		}
	}
	cout << sum;
	return 0;
}